#include <linux/errno.h>
#include <linux/miscdevice.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/mutex.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/device.h>
#include <asm/io.h>
#include "led_opr.h"
#include "led_resource.h"

static struct led_resource *led_rsc;

static int board_led_init(int which)
{
    if(!led_rsc)
	{
		led_rsc = board_led_resource_get();
	}

	printk("init gpio: group %d, pin %d\n", GROUP(led_rsc->pin), PIN(led_rsc->pin));
	switch(GROUP(led_rsc->pin))
    {
		case 0 :
		{
			printk("Init pin of gpro 1 ......\n");
			break;
		}
		case 1:
		{
			printk("Init pin of gpro 1 ......\n");
			break;
		}
		case 2:
		{
			printk("Init pin of gpro 1 ......\n");
			break;
		}

    }
    return 0;
}


static int board_led_ctl(int which, char status)
{
	printk("set led %s: group %d, pin %d\n", status ? "on" : "off", GROUP(led_rsc->pin), PIN(led_rsc->pin));

	switch(GROUP(led_rsc->pin))
	{
		case 0:
		{
			printk("set pin of group 0 ...\n");
			break;
		}
		case 1:
		{
			printk("set pin of group 1 ...\n");
			break;
		}
		case 2:
		{
			printk("set pin of group 2 ...\n");
			break;
		}
		case 3:
		{
			printk("set pin of group 3 ...\n");
			break;
		}
    }
	return 0;
}

static int board_led_destroy(void)
{
	led_rsc = NULL;
	return 0;
}

static struct led_oprations board_demo_led_opr = {
    .num        = 1,
    .init       = board_led_init,
    .ctl        = board_led_ctl,
    .destroy    = board_led_destroy,
};

struct led_oprations *get_board_led_opr(void)
{
    return &board_demo_led_opr;
}
